/*

 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "section")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Section.findAll", query = "SELECT s FROM Section s"),
    @NamedQuery(name = "Section.findBySectionId", query = "SELECT s FROM Section s WHERE s.sectionId = :sectionId"),
    @NamedQuery(name = "Section.findByArticleId", query = "SELECT s FROM Section s WHERE s.articleId.articleId = :articleId"),//with article
    @NamedQuery(name = "Section.findByArticleIdArtive", query = "SELECT s FROM Section s WHERE s.articleId.articleId = :articleId AND s.active = :active"),//Articles active
    @NamedQuery(name = "Section.findByTittle", query = "SELECT s FROM Section s WHERE s.tittle = :tittle"),
    @NamedQuery(name = "Section.findSectionWithRegionId", query = "SELECT s FROM Section s WHERE  s.articleId.regionId.regionId = :regionId AND s.active = :active"),
    @NamedQuery(name = "Section.findByDescriptions", query = "SELECT s FROM Section s WHERE s.descriptions = :descriptions"),
    @NamedQuery(name = "Section.findDistinctSectionWithRegionId", query = "SELECT DISTINCT s.articleId.articleId, s.articleId.tittle, s.articleId.image, s.articleId.detailTittle FROM Section s WHERE s.articleId.regionId.regionId = :regionId AND s.active = :active"),
    @NamedQuery(name = "Section.findByImage", query = "SELECT s FROM Section s WHERE s.image = :image"),
    @NamedQuery(name = "Section.findByActive", query = "SELECT s FROM Section s WHERE s.active = :active")})
public class Section implements Serializable {
    private static final long serialVersionUID = 1L;
    /*
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "sectionId")*/
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer sectionId;
    @Column(name = "tittle")
    private String tittle;
    @Basic(optional = false)
    @Column(name = "descriptions")
    private String descriptions;
    @Column(name = "image")
    private String image;
    @Column(name = "active")
    private Boolean active;
    @JoinColumn(name = "articleId", referencedColumnName = "articleId")
    @ManyToOne
    private Article articleId;

    public Section() {
    }

    public Section(Integer sectionId) {
        this.sectionId = sectionId;
    }
    
    public Section(Integer sectionId, Article articleId, String tittle, String descriptions, String image, Boolean active){
    	this.sectionId = sectionId;
    	this.articleId = articleId;
    	this.tittle = tittle;
    	this.descriptions = descriptions;
    	this.image = image;
    	this.active = active;    	
    }

    public Section(Integer sectionId, String descriptions) {
        this.sectionId = sectionId;
        this.descriptions = descriptions;
    }

    public Integer getSectionId() {
        return sectionId;
    }

    public void setSectionId(Integer sectionId) {
        this.sectionId = sectionId;
    }

    public String getTittle() {
        return tittle;
    }

    public void setTittle(String tittle) {
        this.tittle = tittle;
    }

    public String getDescriptions() {
        return descriptions;
    }

    public void setDescriptions(String descriptions) {
        this.descriptions = descriptions;
    }

    public String getImage() {
        return image;
    }

    public void setImage(String image) {
        this.image = image;
    }

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    public Article getArticleId() {
        return articleId;
    }

    public void setArticleId(Article articleId) {
        this.articleId = articleId;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (sectionId != null ? sectionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Section)) {
            return false;
        }
        Section other = (Section) object;
        if ((this.sectionId == null && other.sectionId != null) || (this.sectionId != null && !this.sectionId.equals(other.sectionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Section[ sectionId=" + sectionId + " ]";
    }
    
}
